<template>
	<view class="content">
		<view class="addTop">
			<view class="nameBox">
				<view class="nameLeft">
					<text class="name">姓名</text>
					<text class="wyyname">
						ئىسىم
					</text>
				</view>
				<view class="nameRight">
					<input class="inputname" v-model="name" type="text" placeholder="请输入姓名" />
				    <text class="wyyname">
						ئىسىم - فامىلىڭىزنى كىرگۈزۈڭ 
				    </text>
				</view>
			</view>
			<view class="nameBox">
				<view class="nameLeft">
					<text class="name">联系电话</text>
					<text class="wyyname">
				        ئالاقىلىشىش تېلېفون نومۇرى 
					</text>
				</view>
				<view class="nameRight">
					<input class="inputname" v-model="mobile" type="text" placeholder="请输入电话" />
				    <text class="wyyname">
						تېلېفون كىرگۈزۈڭ 
				    </text>
				</view>
			</view>
			<view class="nameBox">
				<view class="nameLeft">
					<text class="name">身份证号码</text>
					<text class="wyyname">
						كىملىك نومۇرى 
					</text>
				</view>
				<view class="nameRight">
					<input class="inputname" v-model="IDcard" type="idcard" placeholder="请输入身份号码" />
				    <text class="wyyname">
						كىملىك نومۇرىنى كىرگۈزۈڭ 
				    </text>
				</view>
			</view>
		</view>
		<view class="tianjiaBox" @click="submit">
			<text class="tianjia">{{id?'修改':'提交'}}</text>
			<text class="wyytianjia">
				تاپشۇرۇش
			</text>
		</view>
	</view>
</template>

<script>
	import app from '@/util/api.js'
	export default {
		data() {
			return {
				name:"",
				mobile:"",
				IDcard:"",
				id:""
			}
		},
		methods: {
			submit(){
				if(!this.name){
					app.toast("请输入姓名")
					return
				}
				if(!app.isphoneNumber(this.mobile)){
					app.toast('请输入正确手机号')
					return
				}
				if(!this.IDcard){
					app.toast("请输入正确身份证号")
					return
				}
				app.load()
				let data = {
					name:this.name,
					mobile:this.mobile,
					IDcard:this.IDcard,
				}
			   if(this.id){
						data.id = this.id
			   }
				app.request("user/operator_edit",data,"POST").then(res => {
					app.hide()
					if(this.id){
						app.toast("修改成功")
					}else{
						app.toast("提交成功")
					}
					setTimeout(()=>{
						app.back()
					},500)
					
				})
			},
			getadsinfo(){
				app.load()
				let data = {
					id:this.id
				}
				app.request("user/operator",data).then(res=>{
					let ads = res.data
					this.name = ads.name
					this.mobile = ads.mobile
					this.IDcard = ads.IDcard
					app.hide()
				})
			},
		
		},
		onLoad(o) {
			this.id = o.id
		    this.getadsinfo()
		}
	}
</script>

<style scoped>
    .content{
		min-height: 100vh;
		background-color: #f5f5f5;
	}
	.addTop{
		background-color: #FFFFFF;
		padding: 0 30rpx;
	}
	.nameBox{
		border-bottom: 1rpx #eee solid;
		padding: 35rpx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 24rpx;
		color: #999999;
	}
	.nameBox:nth-last-child(1){
		border-bottom: 0rpx #eee solid;
	}
	.nameLeft{
		display: flex;
		flex-direction: column;
	}
	.name{
		font-size: 30rpx;
		color: #333333;
	}
	.wyyname{
		padding-top: 18rpx;
	}
	.nameRight{
		display: flex;
		flex-direction: column;
		align-items: flex-end;
	}
	.inputname{
		font-size: 30rpx;
		text-align: right;
		min-width: 360rpx;
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}
	.tianjiaBox{
		width: 100vw;
		background-color: #FFC03C;
		padding: 22rpx 0 16rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		color: #FFFFFF;
		font-size: 30rpx;
		position: fixed;
		bottom: 0;
	}
	.wyytianjia{
		font-size: 24rpx;
		padding-top: 13rpx;
	}
</style>
